# -*- coding:utf-8 -*-

from werkzeug.routing import BaseConverter
import functools
from flask import session,make_response,redirect
from flask_wtf.csrf import generate_csrf

class RegexConverter(BaseConverter):
    def __init__(self, url_map, *args):
        super(RegexConverter, self).__init__(url_map)
        self.regex = args[0]

def login_check(f):
    @functools.wraps(f)
    def wrapper(*args, **kwargs):
        user_id = session.get('user_id')
        if user_id is None:
            return redirect('v1.0/login')
        else:
            return f(*args, **kwargs)
    return wrapper







